/*
 * Created by JFormDesigner on Wed Jun 26 15:34:19 CST 2024
 */

package scct.zhang.ui;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

/**
 * @author 张
 */
public class FormMain extends JFrame {
    public FormMain() {
        initComponents();
    }

    private void mnuUser(ActionEvent e) {
        // TODO add your code here
        PanelUserManger panelUserManger = new PanelUserManger(this);
//        先把已经加载的其他管理面板移出
        panelMain.removeAll();
//        加载用户管理面板
        panelMain.add(panelUserManger,BorderLayout.CENTER);
//        刷新页面
        validate();
    }

    private void btnContact(ActionEvent e) {
        // TODO add your code here
        PanelContactManger panelContactManger = new PanelContactManger(this);
        //        先把已经加载的其他管理面板移出
        panelMain.removeAll();
        //        加载用户管理面板
        panelMain.add(panelContactManger,BorderLayout.CENTER);
        //        刷新页面
        validate();
    
    }

    private void mnuContact(ActionEvent e) {
        // TODO add your code here
        PanelContactManger panelContactManger = new PanelContactManger(this);
        //        先把已经加载的其他管理面板移出
        panelMain.removeAll();
        //        加载用户管理面板
        panelMain.add(panelContactManger,BorderLayout.CENTER);
        //        刷新页面
        validate();

    }

    private void btnGroup(ActionEvent e) {
        // TODO add your code here
        PanelGroup panelGroup = new PanelGroup(this);
        panelMain.removeAll();
        panelMain.add(panelGroup,BorderLayout.CENTER);
        validate();
    }

    private void mnuGroup(ActionEvent e) {
        // TODO add your code here
        PanelGroup panelGroup = new PanelGroup(this);
        panelMain.removeAll();
        panelMain.add(panelGroup,BorderLayout.CENTER);
        validate();
    }

    private void mnuConversation(ActionEvent e) {
        // TODO add your code here
        PanelConversation panelConversation = new PanelConversation(this);
        panelMain.removeAll();
        panelMain.add(panelConversation,BorderLayout.CENTER);
        validate();
    }

    private void btnConversation(ActionEvent e) {
        // TODO add your code here
        PanelConversation panelConversation = new PanelConversation(this);
        panelMain.removeAll();
        panelMain.add(panelConversation,BorderLayout.CENTER);
        validate();
    }

    private void btnChatrecord(ActionEvent e) {
        // TODO add your code here
        PanelChatRecord panelChatRecord = new PanelChatRecord(this);
        panelMain.removeAll();
        panelMain.add(panelChatRecord,BorderLayout.CENTER);
        validate();
        
    }

    private void mnuChatrecord(ActionEvent e) {
        // TODO add your code here
        PanelChatRecord panelChatRecord = new PanelChatRecord(this);
        panelMain.removeAll();
        panelMain.add(panelChatRecord,BorderLayout.CENTER);
        validate();

    }

    private void mnuExit(ActionEvent e) {
        // TODO add your code here
        this.dispose();
        FormLogin login = new FormLogin();
        login.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        login.setVisible(true);



    }


    private void initComponents() {
        // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents  @formatter:off
        // Generated using JFormDesigner Evaluation license - zhang
        menuBar1 = new JMenuBar();
        menu1 = new JMenu();
        mnuUser = new JMenuItem();
        mnuExit = new JMenuItem();
        menu2 = new JMenu();
        mnuContact = new JMenuItem();
        mnuGroup = new JMenuItem();
        mnuConversation = new JMenuItem();
        mnuChatrecord = new JMenuItem();
        menu3 = new JMenu();
        mnuAbout = new JMenuItem();
        toolBar1 = new JToolBar();
        btnContact = new JButton();
        btnGroup = new JButton();
        btnConversation = new JButton();
        btnChatrecord = new JButton();
        panelMain = new JPanel();
        label1 = new JLabel();

        //======== this ========
        setTitle("\u804a\u5929\u8bb0\u5f55\u7ba1\u7406\u7cfb\u7edf");
        var contentPane = getContentPane();
        contentPane.setLayout(new BorderLayout());

        //======== menuBar1 ========
        {

            //======== menu1 ========
            {
                menu1.setText("\u7cfb\u7edf");

                //---- mnuUser ----
                mnuUser.setText("\u7528\u6237\u7ba1\u7406");
                mnuUser.addActionListener(e -> mnuUser(e));
                menu1.add(mnuUser);

                //---- mnuExit ----
                mnuExit.setText("\u9000\u51fa");
                mnuExit.addActionListener(e -> mnuExit(e));
                menu1.add(mnuExit);
            }
            menuBar1.add(menu1);

            //======== menu2 ========
            {
                menu2.setText("\u7ba1\u7406");

                //---- mnuContact ----
                mnuContact.setText("\u8054\u7cfb\u4eba\u7ba1\u7406");
                mnuContact.addActionListener(e -> mnuContact(e));
                menu2.add(mnuContact);

                //---- mnuGroup ----
                mnuGroup.setText("\u7fa4\u7ec4\u7ba1\u7406");
                mnuGroup.addActionListener(e -> mnuGroup(e));
                menu2.add(mnuGroup);

                //---- mnuConversation ----
                mnuConversation.setText("\u4f1a\u8bdd\u7ba1\u7406");
                mnuConversation.addActionListener(e -> mnuConversation(e));
                menu2.add(mnuConversation);

                //---- mnuChatrecord ----
                mnuChatrecord.setText("\u804a\u5929\u8bb0\u5f55\u7ba1\u7406");
                mnuChatrecord.addActionListener(e -> mnuChatrecord(e));
                menu2.add(mnuChatrecord);
            }
            menuBar1.add(menu2);

            //======== menu3 ========
            {
                menu3.setText("\u5173\u4e8e");

                //---- mnuAbout ----
                mnuAbout.setText("\u6211\u7684\u9879\u76ee");
                menu3.add(mnuAbout);
            }
            menuBar1.add(menu3);
        }
        setJMenuBar(menuBar1);

        //======== toolBar1 ========
        {

            //---- btnContact ----
            btnContact.setIcon(new ImageIcon(getClass().getResource("/icon/yonghu.png")));
            btnContact.setToolTipText("\u8054\u7cfb\u4eba\u7ba1\u7406");
            btnContact.addActionListener(e -> btnContact(e));
            toolBar1.add(btnContact);

            //---- btnGroup ----
            btnGroup.setIcon(new ImageIcon(getClass().getResource("/icon/qun.png")));
            btnGroup.setToolTipText("\u7fa4\u7ec4\u7ba1\u7406");
            btnGroup.addActionListener(e -> btnGroup(e));
            toolBar1.add(btnGroup);

            //---- btnConversation ----
            btnConversation.setIcon(new ImageIcon(getClass().getResource("/icon/huihua.png")));
            btnConversation.setToolTipText("\u4f1a\u8bdd\u7ba1\u7406");
            btnConversation.addActionListener(e -> btnConversation(e));
            toolBar1.add(btnConversation);

            //---- btnChatrecord ----
            btnChatrecord.setIcon(new ImageIcon(getClass().getResource("/icon/liao.png")));
            btnChatrecord.setToolTipText("\u804a\u5929\u8bb0\u5f55");
            btnChatrecord.addActionListener(e -> btnChatrecord(e));
            toolBar1.add(btnChatrecord);
        }
        contentPane.add(toolBar1, BorderLayout.NORTH);

        //======== panelMain ========
        {
            panelMain.setBorder(new javax.swing.border.CompoundBorder(new javax.swing.border.TitledBorder(new javax.swing.border.EmptyBorder(
            0,0,0,0), "JFor\u006dDesi\u0067ner \u0045valu\u0061tion",javax.swing.border.TitledBorder.CENTER,javax.swing.border.TitledBorder
            .BOTTOM,new java.awt.Font("Dia\u006cog",java.awt.Font.BOLD,12),java.awt.Color.
            red),panelMain. getBorder()));panelMain. addPropertyChangeListener(new java.beans.PropertyChangeListener(){@Override public void propertyChange(java.
            beans.PropertyChangeEvent e){if("bord\u0065r".equals(e.getPropertyName()))throw new RuntimeException();}});
            panelMain.setLayout(new BorderLayout());

            //---- label1 ----
            label1.setText("Hello");
            label1.setHorizontalAlignment(SwingConstants.CENTER);
            label1.setFont(new Font("Haettenschweiler", label1.getFont().getStyle(), 88));
            panelMain.add(label1, BorderLayout.CENTER);
        }
        contentPane.add(panelMain, BorderLayout.CENTER);
        setSize(530, 420);
        setLocationRelativeTo(getOwner());
        // JFormDesigner - End of component initialization  //GEN-END:initComponents  @formatter:on
    }

    // JFormDesigner - Variables declaration - DO NOT MODIFY  //GEN-BEGIN:variables  @formatter:off
    // Generated using JFormDesigner Evaluation license - zhang
    private JMenuBar menuBar1;
    private JMenu menu1;
    private JMenuItem mnuUser;
    private JMenuItem mnuExit;
    private JMenu menu2;
    private JMenuItem mnuContact;
    private JMenuItem mnuGroup;
    private JMenuItem mnuConversation;
    private JMenuItem mnuChatrecord;
    private JMenu menu3;
    private JMenuItem mnuAbout;
    private JToolBar toolBar1;
    private JButton btnContact;
    private JButton btnGroup;
    private JButton btnConversation;
    private JButton btnChatrecord;
    private JPanel panelMain;
    private JLabel label1;
    // JFormDesigner - End of variables declaration  //GEN-END:variables  @formatter:on
}
